package com.huawei;

import java.util.*;

/**
 * Created by Z-hong on 2024/7/24.
 */

public class HJ77 {
    static Set<String> set = new HashSet<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; i++) {
            arr[i] = sc.nextInt();
        }
        sort(arr, 0, "", new Stack<Integer>());
        ArrayList<String> res = new ArrayList<>(set);
        Collections.sort(res, (a, b) -> a.compareTo(b));

        for (String s : res) {

            System.out.println(s);
        }
    }

    public static void sort(int[] arr, int i, String str, Stack<Integer> stack) {
        if (stack.isEmpty() && i == arr.length) {
            set.add(str);
        }
        //添加
        if (i < arr.length) {
            Stack<Integer> temp = new Stack<>();
            temp.addAll(stack);
            temp.push(arr[i]);
            sort(arr, i + 1, str, temp);
        }
        //出栈

        if (!stack.isEmpty()) {
            Stack<Integer> temp = new Stack<>();
            temp.addAll(stack);
            if(str.isEmpty()){
                str+=temp.pop();
            }else{
                str=str + " " + temp.pop();
            }
            sort(arr, i,str, temp);
        }
    }
}
